[rgh-sticky-sidebar-enabled] #js-repo-pjax-container ul.pagehead-actions,
/* https://github.com/refined-github/refined-github/issues/6761 */
[rgh-sticky-sidebar-enabled] [id^='my-forks-menu'] {
	z-index: initial !important; /* This affects the social buttons. It seems to have no effect but it constantly causes trouble with other features. */
}

/*
Have the calculations available even when the sidebar isn't sticky so that `--rgh-sticky-sidebar-offset` can be used via JS.

Exclusively use simple sums and use `0px` instead of `0`
 */
#partial-discussion-sidebar {
	--rgh-sticky-header-height: 60px;
	--rgh-sticky-sidebar-offset: calc(
		var(--rgh-sticky-header-height, 0px) +
			var(--rgh-sticky-notifitication-header-height, 0px)
	);
}

.notification-shelf ~ .application-main #partial-discussion-sidebar {
	--rgh-sticky-notifitication-header-height: 69px;
}

.rgh-sticky-sidebar {
	position: sticky;
	top: var(--rgh-sticky-sidebar-offset, 0) !important;

	/* `sticky` will trap the `fixed` dialog’s z-index in some sidebars #3732 */
	/* Higher than sticky readme header #4192 */
	z-index: 90;
}

#partial-discussion-sidebar.rgh-sticky-sidebar {
	z-index: 1;
}

/* Hides the last divider (on pull requests) to avoid https://user-images.githubusercontent.com/10238474/62282128-af6fb980-b457-11e9-8b18-c29687b88da1.gif */
.rgh-sticky-sidebar + .border-top {
	display: none;
}

/* Avoid z-index issue with Stars dropdown in repo header #5214 */
[rgh-sticky-sidebar-enabled] .pagehead-actions .js-user-list-menu {
	z-index: unset;
}

/* z-index fights 🥲 This is the search dropdown on the repo root #6151 */
html[rgh-sticky-sidebar-enabled]:has(.rgh-sticky-sidebar)
	.search-input.expanded
	.search-with-dialog {
	z-index: 95; /* Native: 35 */
}

html[rgh-sticky-sidebar-enabled]:has(.rgh-sticky-sidebar)
	.search-input.expanded
	.dark-backdrop {
	z-index: 92; /* Native: 32 */
}
